﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using System.Data;
using System.Data.Sql;
using System.Data.SqlClient;

namespace SportingGoodsExhibitionSystem
{
    /// <summary>
    /// AdminStuBackInfo.xaml 的交互逻辑
    /// </summary>
    public partial class AdminStuBackInfo : Window
    {
        public AdminStuBackInfo()
        {
            InitializeComponent();
        }

        int stuNum;
        string strCon = Properties.Resources.strCON;

        public AdminStuBackInfo(int stuNum)
        {
            InitializeComponent();
            this.stuNum = stuNum;
        }

        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            SqlConnection con = new SqlConnection(strCon);
            con.Open();
            SqlCommand cmd = new SqlCommand("select * from backInfo where stunum=@num", con);
            cmd.Parameters.Add("@num", SqlDbType.Int, 10).Value = stuNum;
            SqlDataAdapter read = new SqlDataAdapter(cmd);
            //DataTable dt = new DataTable();
            DataSet dataset = new DataSet();
            read.Fill(dataset);
            DataTable table = dataset.Tables[0];
            DataRowCollection rows = table.Rows;
            DataRow row = rows[0];
            
            labelNowPlace.Content = row["nowaddr"].ToString();
            labelDetail.Content = row["detailaddr"].ToString();
            labelTime.Content = row["arrivetime"].ToString();
            labelArriveplace.Content = row["arriveplace"].ToString();
            labelHouse.Content = row["houseplace"];
            labelNum.Content = row["housenum"];
            int a = Convert.ToInt32(row["whigh"]);
            int b = Convert.ToInt32(row["wme"]);
            int c = Convert.ToInt32(row["wagree"]);
            if(a==0)
            {
                wpassHigh.Content = "否";
            }
            else
            {
                wpassHigh.Content = "是";
            }
            if (b == 0)
            {
                wMyself.Content = "否";
            }
            else
            {
                wMyself.Content = "是";
            }
            if (c == 0)
            {
                wAgreed.Content = "否";
            }
            else
            {
                wAgreed.Content = "是";
            }
            con.Close();
        }
    }
}
